﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Radius.NET.Interface.Kingdee.Entity
{
    public class PUR_MRB : KingdeePubClass
    {
        /// <summary>
        /// 实体
        /// </summary>
        public PUR_MRB_Model? Model { get; set; }

        #region 采购退料单表头
        public class PUR_MRB_Model
        {
            /// <summary>
            /// 
            /// </summary>
            public int FID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FBillTypeID FBillTypeID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FBillNo { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public DateTime? FDate { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FMRTYPE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FMRMODE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FStockOrgId FStockOrgId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FMRDeptId FMRDeptId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FSTOCKERGROUPID FSTOCKERGROUPID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FCorrespondOrgId FCorrespondOrgId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FSTOCKERID FSTOCKERID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FMRREASON FMRREASON { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FRequireOrgId FRequireOrgId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPurchaseOrgId FPurchaseOrgId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPURCHASEDEPTID FPURCHASEDEPTID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPURCHASERGROUPID FPURCHASERGROUPID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPURCHASERID FPURCHASERID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FSUPPLIERID FSupplierID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FDESCRIPTION { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FACCEPTORID FACCEPTORID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FAcceptAddress { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FSettleId FSettleId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FCHARGEID FCHARGEID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FOwnerTypeIdHead { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FOwnerIdHead FOwnerIdHead { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FScanPoint FScanPoint { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FConfirmerId FConfirmerId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FConfirmDate { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FScanBox { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FCDateOffsetUnit { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FCDateOffsetValue { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FAcceptorContactID FAcceptorContactID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string F_GDRJ_PrintDateTime { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int F_GDRJ_PrintTimes { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPURMRBFIN FPURMRBFIN { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public List<FPURMRBENTRYItem> FPURMRBENTRY { get; set; }
        }
        #endregion

        #region 采购退料单明细
        public class FPURMRBENTRYItem
        {
            /// <summary>
            /// 
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FRowType { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FMaterialId FMATERIALID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FMaterialDesc { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FParentMatId FParentMatId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FProjectNo { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FUnitID FUnitID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FRMREALQTY { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FREPLENISHQTY { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FKEAPAMTQTY { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPriceUnitID FPRICEUNITID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FStockId FSTOCKID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FStockLocId FSTOCKLOCID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FStockStatusId FStockStatusId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FNOTE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FTaxCombination FTaxCombination { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FPrice { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FExtAuxUnitId FExtAuxUnitId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FExtAuxUnitQty { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FREQTRACENO { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public bool FIsReceiveUpdateStock { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FInvoicedJoinQty { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public bool FGiveAway { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FPriceBaseQty { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FSetPriceUnitID FSetPriceUnitID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FCarryUnitId FCarryUnitId { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FCarryQty { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FCarryBaseQty { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FPOORDERENTRYID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public bool FBILLINGCLOSE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FPriceListEntry FPriceListEntry { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FAuxPropId FAuxPropID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FRMMUSTQTY { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FBomId FBOMID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FSupplierLot { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FLot FLot { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FProduceDate { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FEXPIRYDATE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FAUXUNITQTY { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FOWNERTYPEID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FOwnerId FOWNERID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FENTRYTAXRATE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FDISCOUNTRATE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FTAXPRICE { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FPriceDiscount { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public bool FIsStock { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public FChargeProjectID FChargeProjectID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FMtoNo { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public List<FEntryPruCostItem> FEntryPruCost { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public List<FTaxDetailSubEntityItem> FTaxDetailSubEntity { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public List<FSerialSubEntityItem> FSerialSubEntity { get; set; }
        }
        #endregion

        #region 其他
        public class FStockLocId
        {
            public FSTOCKLOCID__FF100002_Model FSTOCKLOCID__FF100002 { get; set; }
            public FSTOCKLOCID__FF100006_Model FSTOCKLOCID__FF100006 { get; set; }
            public FSTOCKLOCID__FF100008_Model FSTOCKLOCID__FF100008 { get; set; }
            public FSTOCKLOCID__FF100010_Model FSTOCKLOCID__FF100010 { get; set; }
            public FSTOCKLOCID__FF100011_Model FSTOCKLOCID__FF100011 { get; set; }
            public FSTOCKLOCID__FF100012_Model FSTOCKLOCID__FF100012 { get; set; }
            public FSTOCKLOCID__FF100013_Model FSTOCKLOCID__FF100013 { get; set; }
            public FSTOCKLOCID__FF100014_Model FSTOCKLOCID__FF100014 { get; set; }
            public FSTOCKLOCID__FF100015_Model FSTOCKLOCID__FF100015 { get; set; }


            public class FSTOCKLOCID__FF100002_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100006_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100008_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100010_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100011_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100012_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100013_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100014_Model
            {
                public string FNumber { set; get; }
            }
            public class FSTOCKLOCID__FF100015_Model
            {
                public string FNumber { set; get; }
            }
        }
        public class FAuxPropId
        {
            public FAUXPROPID__FF100002_Model FAUXPROPID__FF100002 { set; get; }
            public FAUXPROPID__FF100003_Model FAUXPROPID__FF100003 { set; get; }
            public FAUXPROPID__FF100004_Model FAUXPROPID__FF100004 { set; get; }

            public class FAUXPROPID__FF100002_Model
            {
                public string FNumber { set; get; }
            }
            public class FAUXPROPID__FF100003_Model
            {
                public string FNumber { set; get; }
            }
            public class FAUXPROPID__FF100004_Model
            {
                public string FNumber { set; get; }
            }
        }
        public class FEntryPruCostItem
        {
            /// <summary>
            /// 
            /// </summary>
            public int FDetailID { get; set; }
        }

        public class FTaxDetailSubEntityItem
        {
            /// <summary>
            /// 
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public int FTaxRate { get; set; }
        }

        public class FSerialSubEntityItem
        {
            /// <summary>
            /// 
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FSerialNo { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string FSerialNote { get; set; }
        } 
        #endregion
        

        public object BuildData(InventoryEvidence item, List<PUR_PurchaseOrderDto> pUR_ReceiveBillDto)
        {
            var obj = new PUR_MRB()
            {
                Model = new()
                {
                    FID = 0,
                    FBillTypeID = new()
                    {
                        FNumber = "TLD01_SYS"
                    },
                    FBillNo = item.Evidence_Number,
                    FDate = item.Date,
                    FMRTYPE = "B",
                    FMRMODE = "B",
                    FStockOrgId = new()
                    {
                        FNumber = "BJ"
                    },
                    FMRDeptId = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKERGROUPID = new ()
                    {
                        FNumber = ""
                    },
                    FCorrespondOrgId = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKERID = new ()
                    {
                        FNumber = ""
                    },
                    FMRREASON = new FMRREASON()
                    {
                        FNumber = ""
                    },
                    FRequireOrgId = new FRequireOrgId()
                    {
                        FNumber = "BJ"
                    },
                    FPurchaseOrgId = new ()
                    {
                        FNumber = "BJ"
                    },
                    FPURCHASEDEPTID = new ()
                    {
                        FNumber = "BM0004"
                    },
                    FPURCHASERGROUPID = new ()
                    {
                        FNumber = ""
                    },
                    FPURCHASERID = new ()
                    {
                        FNumber = ""
                    },
                    FSupplierID = new ()
                    {
                        FNumber = "" //供应商编码
                    },
                    FDESCRIPTION = "",
                    FACCEPTORID = new FACCEPTORID()
                    {
                        FNumber = ""
                    },
                    FAcceptAddress = "",
                    FSettleId = new ()
                    {
                        FNumber = ""
                    },
                    FCHARGEID = new FCHARGEID()
                    {
                        FNumber = ""
                    },
                    FOwnerTypeIdHead = "BD_OwnerOrg",
                    FOwnerIdHead = new ()
                    {
                        FNumber = "BJ"
                    },
                    FScanPoint = new FScanPoint()
                    {
                        FNUMBER = ""
                    },
                    FConfirmerId = new FConfirmerId()
                    {
                        FUserID = ""
                    },
                    FConfirmDate = "1900-01-01",
                    FScanBox = "",
                    FCDateOffsetUnit = "",
                    FCDateOffsetValue = 0,
                    FAcceptorContactID = new FAcceptorContactID()
                    {
                        FCONTACTNUMBER = ""
                    },
                    F_GDRJ_PrintDateTime = "1900-01-01",
                    F_GDRJ_PrintTimes = 0,
                    FPURMRBFIN = new FPURMRBFIN()
                    {
                        FEntryId = 0,
                        FSettleOrgId = new ()
                        {
                            FNumber = "BJ"
                        },
                        FSETTLETYPEID = new()
                        {
                            FNumber = ""
                        },
                        FSettleCurrId = new FSettleCurrId()
                        {
                            FNumber = "PRE001"
                        },
                        FPAYCONDITIONID = new FPAYCONDITIONID()
                        {
                            FNumber = "006"
                        },
                        FIsIncludedTax = true,
                        FPRICETIMEPOINT = "1",
                        FPRICELISTID = new FPRICELISTID()
                        {
                            FNumber = ""
                        },
                        FDISCOUNTLISTID = new FDISCOUNTLISTID()
                        {
                            FNumber = ""
                        },
                        FLOCALCURRID = new FLOCALCURRID()
                        {
                            FNumber = ""
                        },
                        FEXCHANGETYPEID = new FEXCHANGETYPEID()
                        {
                            FNumber = "HLTX01_SYS"
                        },
                        FEXCHANGERATE = 1,
                        FISPRICEEXCLUDETAX = true

                    },
                    FPURMRBENTRY = new List<FPURMRBENTRYItem>()
                }
            };
            obj.Model.FPURMRBENTRY.Add(new ()
            {

                FEntryID = 0,
                FRowType = "Standard",
                FMATERIALID = new ()
                {
                    FNumber = "" //物料编码
                },
                FMaterialDesc = "", //物料名称
                FParentMatId = new FParentMatId()
                {
                    FNumber = ""
                },
                FProjectNo = "",
                FUnitID = new ()
                {
                    FNumber = "" //单位
                },
                FRMREALQTY = 0, //实退数量
                FREPLENISHQTY = 0,
                FKEAPAMTQTY = 0, //扣款数量
                FPRICEUNITID = new ()
                {
                    FNumber = "" //单位
                },
                FSTOCKID = new ()
                {
                    FNumber = "" //仓库
                },
                FSTOCKLOCID = new ()
                {
                    FSTOCKLOCID__FF100002 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100006 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100008 = new ()
                    {
                        FNumber = "" //仓位
                    },
                    FSTOCKLOCID__FF100010 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100011 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100012 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100013 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100014 = new ()
                    {
                        FNumber = ""
                    },
                    FSTOCKLOCID__FF100015 = new ()
                    {
                        FNumber = ""
                    }
                },
                FStockStatusId = new ()
                {
                    FNumber = "KCZT01_SYS"
                },
                FNOTE = "",
                FTaxCombination = new FTaxCombination()
                {
                    FNumber = ""
                },
                FPrice = 0, //单价
                FExtAuxUnitId = new ()
                {
                    FNumber = ""
                },
                FExtAuxUnitQty = 0,
                FREQTRACENO = "",
                FIsReceiveUpdateStock = false,
                FInvoicedJoinQty = 0,
                FGiveAway = false,
                FPriceBaseQty = 0, //计价基本数量
                FSetPriceUnitID = new FSetPriceUnitID()
                {
                    FNumber = ""
                },
                FCarryUnitId = new FCarryUnitId()
                {
                    FNumber = "" //采购单位
                },
                FCarryQty = 0, //采购数量
                FCarryBaseQty = 0, //采购基本数量
                FPOORDERENTRYID = 0, //采购订单分录内码
                FBILLINGCLOSE = true,
                FPriceListEntry = new FPriceListEntry()
                {
                    FNUMBER = ""
                },
                FAuxPropID = new ()
                {
                    FAUXPROPID__FF100002 = new()
                    {
                        FNumber = ""
                    },
                    FAUXPROPID__FF100003 = new()
                    {
                        FNumber = ""
                    },
                    FAUXPROPID__FF100004 = new()
                    {
                        FNumber = ""
                    }
                },
                FRMMUSTQTY = 0,
                FBOMID = new ()
                {
                    FNumber = ""
                },
                FSupplierLot = "",
                FLot = new ()
                {
                    FNumber = "" //批号
                },
                FProduceDate = "",
                FEXPIRYDATE = "",
                FAUXUNITQTY = 0,
                FOWNERTYPEID = "BD_OwnerOrg",
                FOWNERID = new ()
                {
                    FNumber = "BJ"
                },
                FENTRYTAXRATE = 0,
                FDISCOUNTRATE = 0,
                FTAXPRICE = 0, //含税单价
                FPriceDiscount = 0,
                FIsStock = true,
                FChargeProjectID = new ()
                {
                    FNumber = ""
                },
                FMtoNo = "",
                FEntryPruCost = new List<FEntryPruCostItem>() {
                    new ()
                    {
                        FDetailID= 0
                    }
                },
                FTaxDetailSubEntity = new List<FTaxDetailSubEntityItem>()
                {
                    new ()
                    {
                        FDetailID = 0,
                        FTaxRate = 0
                    }
                },
                FSerialSubEntity = new List<FSerialSubEntityItem>()
                {
                    new ()
                    {
                        FDetailID= 0,
                        FSerialNo= "",
                        FSerialNote= ""
                    }
                }
            });
            return obj;
        }
    }
}
